/**
 * \file URI.h
 * \brief URI definition class
 * \author Edouard ROGE
 * \date 19 septembre 2010
 */

#ifndef _URI_
#define _URI_

#include <mutex>
#include <string>
#include "Core/Memory/HeapObject.h"

namespace Core
{
	namespace File
	{
		/**
		 * \class URI
		 * \brief store information for a given URI: path, filename and file extension
		 */
		class URI : public Memory::HeapObject
		{
		public:
			/**
			 * \fn URI();
			 * Default constructor
			 */
			URI();


			/**
			 * \fn URI(const URI & _URI);
			 * \param _URI Uri to copy
			 * \brief Copy constructor
			 */
			URI(const URI & _URI);

			/**
			 * \fn URI(const std::string & _strURI);
			 * \param _strURI build path, filename and extension from the complete URI
			 */
			URI(const std::string & _strURI);

			/**
			 * \fn URI(char * _strURI);
			 * \param _strURI build path, filename and extension from the complete URI
			 */
			URI(char * _strURI);

			/**
			 * \fn URI(const char * _strURI);
			 * \param _strURI build path, filename and extension from the complete URI
			 */
			URI(const char * _strURI);

			/**
			 * \fn ~URI();
			 * Destructor
			 */
			~URI();

			/**
			 * \fn inline const std::string & GetPath() const
			 * \return the path corresponding to the URI
			 */
			inline const std::string & GetPath() const { return m_strPath; }

			/**
			 * \fn inline const StringRef & GetFilename() const
			 * \return the file name corresponding to the URI
			 */
			inline const std::string & GetFilename() const { return m_strFileName; }

			/**
			 * \fn inline const StringRef & GetFileExtension() const
			 * \return the extension corresponding to the URI
			 */
			inline const std::string & GetFileExtension() const { return m_strFileExtension; }

			/**
			 * \fn std::string GetURI() const
			 * \return the complete URI
			 */
			std::string GetURI() const;

			/**
			 * \fn bool FileExists() const;
			 * \return true if the file exists
			 */
			bool FileExists() const;

			/**
			 * \fn URI & operator = (const std::string & _strURI);
			 * \param _strURI the new URI
			 * \return (*this)
			 * Set the URI
			 */
			URI & operator = (const std::string & _strURI);

			/**
			 * \fn URI & operator = (char * _strURI);
			 * \param _strURI the new URI
			 * \return (*this)
			 * Set the URI
			 */
			URI & operator = (char * _strURI);

			/**
			 * \fn URI & operator = (const char * _strURI);
			 * \param _strURI the new URI
			 * \return (*this)
			 * Set the URI
			 */
			URI & operator = (const char * _strURI);

		private:

			/**
			 * \fn void Set(const std::string & _strURI);
			 * \param _strURI the new URI
			 * \return (*this)
			 * Set the URI
			 */
			void Set(const std::string & _strURI);

			/** String containing the path */
			std::string m_strPath;

			/** String containing the filename */
			std::string m_strFileName;

			/** String containing the file extension without '.' */
			std::string m_strFileExtension;

			/** Mutex */
			std::mutex m_mutex;
		};
	}
}

#endif //_URI_
